$(document).ready(function () {
    $("#AppPieceForm").submit(function (event) {
        var data = $(this).serialize(),
          action = $(this).attr("action"),
          method = $(this).attr("method");
        $.ajax({
            url: action,
            type: method,
            data: data,
            dataType: "text",
            success: function (dataContent) {
                $.colorbox({ html: dataContent });
            },
            error: function (jqXHR, textStatus, errorThrown) {
                var content = "Server error";
                $.colorbox({ html: textStatus });
            }
        });
        return false;
    });

    if($("#form1Bidding").length == 1)
    {
        var action = window.location + "&ajax=true";
        setInterval(function () {
            $.ajax({
                url: action,
                type: "POST",
                dataType: "text",
                success: function (dataContent) {
                    $("#MainContent_lblHighestBid").html(dataContent);
                }
            });
        }, 1000);
    }

    if ($("#biddingInfoTable").length == 1) {
        $(".highestBidDiv").each(function () {
            var action = "/View/BiddingPage.aspx?id=" + $(this).data("id") + "&ajax=true";
            var that = this;
            setInterval(function () {
                $.ajax({
                    url: action,
                    type: "POST",
                    dataType: "text",
                    success: function (dataContent) {
                        $(that).html(dataContent);
                    }
                });
            }, 1000);
        });
    }
});

